using System;
using System.Collections.Generic;
using System.Text;

using System.Data.SqlClient;
namespace BCB.SQLServerDAL
{
    public class SafeDataReader
    {
        private SqlDataReader dr = null;
        public SafeDataReader(SqlDataReader dr)
        {
            this.dr = dr;
        }
        public int GetInt32(string columnName)
        {
            int columnIndex = dr.GetOrdinal(columnName);
            if (!dr.IsDBNull(columnIndex))
            {
                return dr.GetInt32(columnIndex);
            }
            else
            {
                return 0;
            }
        }
        public string GetString(string columnName)
        {
            int columnIndex = dr.GetOrdinal(columnName);
            if (!dr.IsDBNull(columnIndex))
            {
                return dr.GetString(columnIndex);
            }
            else
            {
                return string.Empty;
            }
        }
        public bool GetBoolean(string columnName)
        {
            int columnIndex = dr.GetOrdinal(columnName);
            if (!dr.IsDBNull(columnIndex))
            {
                return dr.GetBoolean(columnIndex);
            }
            else
            {
                return false;
            }
        }
    }
}
